//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CMatrix {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CMatrix(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CMatrix obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CMatrix(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public static CMatrix getIdentity() {
    long cPtr = nelmiscJNI.CMatrix_Identity_get();
    return (cPtr == 0) ? null : new CMatrix(cPtr, false);
  }

  public CMatrix() {
    this(nelmiscJNI.new_CMatrix__SWIG_0(), true);
  }

  public CMatrix(CMatrix arg0) {
    this(nelmiscJNI.new_CMatrix__SWIG_1(CMatrix.getCPtr(arg0), arg0), true);
  }

  public CMatrix assign(CMatrix arg0) {
    return new CMatrix(nelmiscJNI.CMatrix_assign(swigCPtr, this, CMatrix.getCPtr(arg0), arg0), false);
  }

  public void identity() {
    nelmiscJNI.CMatrix_identity(swigCPtr, this);
  }

  public void setRot(CVector i, CVector j, CVector k, boolean hintNoScale) {
    nelmiscJNI.CMatrix_setRot__SWIG_0(swigCPtr, this, CVector.getCPtr(i), i, CVector.getCPtr(j), j, CVector.getCPtr(k), k, hintNoScale);
  }

  public void setRot(CVector i, CVector j, CVector k) {
    nelmiscJNI.CMatrix_setRot__SWIG_1(swigCPtr, this, CVector.getCPtr(i), i, CVector.getCPtr(j), j, CVector.getCPtr(k), k);
  }

  public void setRot(SWIGTYPE_p_float m33, boolean hintNoScale) {
    nelmiscJNI.CMatrix_setRot__SWIG_2(swigCPtr, this, SWIGTYPE_p_float.getCPtr(m33), hintNoScale);
  }

  public void setRot(SWIGTYPE_p_float m33) {
    nelmiscJNI.CMatrix_setRot__SWIG_3(swigCPtr, this, SWIGTYPE_p_float.getCPtr(m33));
  }

  public void setRot(CVector v, CMatrix.TRotOrder ro) {
    nelmiscJNI.CMatrix_setRot__SWIG_4(swigCPtr, this, CVector.getCPtr(v), v, ro.swigValue());
  }

  public void setRot(CQuat quat) {
    nelmiscJNI.CMatrix_setRot__SWIG_5(swigCPtr, this, CQuat.getCPtr(quat), quat);
  }

  public void setRot(CMatrix matrix) {
    nelmiscJNI.CMatrix_setRot__SWIG_6(swigCPtr, this, CMatrix.getCPtr(matrix), matrix);
  }

  public void setScale(float scale) {
    nelmiscJNI.CMatrix_setScale__SWIG_0(swigCPtr, this, scale);
  }

  public void setScale(CVector v) {
    nelmiscJNI.CMatrix_setScale__SWIG_1(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public void setPos(CVector v) {
    nelmiscJNI.CMatrix_setPos(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public void movePos(CVector v) {
    nelmiscJNI.CMatrix_movePos(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public void setProj(SWIGTYPE_p_float proj) {
    nelmiscJNI.CMatrix_setProj(swigCPtr, this, SWIGTYPE_p_float.getCPtr(proj));
  }

  public void resetProj() {
    nelmiscJNI.CMatrix_resetProj(swigCPtr, this);
  }

  public void set(SWIGTYPE_p_float m44) {
    nelmiscJNI.CMatrix_set(swigCPtr, this, SWIGTYPE_p_float.getCPtr(m44));
  }

  public void setCoefficient(float coeff, int i, int j) {
    nelmiscJNI.CMatrix_setCoefficient(swigCPtr, this, coeff, i, j);
  }

  public void setArbitraryRotI(CVector idir) {
    nelmiscJNI.CMatrix_setArbitraryRotI(swigCPtr, this, CVector.getCPtr(idir), idir);
  }

  public void setArbitraryRotJ(CVector jdir) {
    nelmiscJNI.CMatrix_setArbitraryRotJ(swigCPtr, this, CVector.getCPtr(jdir), jdir);
  }

  public void setArbitraryRotK(CVector kdir) {
    nelmiscJNI.CMatrix_setArbitraryRotK(swigCPtr, this, CVector.getCPtr(kdir), kdir);
  }

  public void getRot(CVector i, CVector j, CVector k) {
    nelmiscJNI.CMatrix_getRot__SWIG_0(swigCPtr, this, CVector.getCPtr(i), i, CVector.getCPtr(j), j, CVector.getCPtr(k), k);
  }

  public void getRot(SWIGTYPE_p_float m33) {
    nelmiscJNI.CMatrix_getRot__SWIG_1(swigCPtr, this, SWIGTYPE_p_float.getCPtr(m33));
  }

  public void getRot(CQuat quat) {
    nelmiscJNI.CMatrix_getRot__SWIG_2(swigCPtr, this, CQuat.getCPtr(quat), quat);
  }

  public CQuat getRot() {
    return new CQuat(nelmiscJNI.CMatrix_getRot__SWIG_3(swigCPtr, this), true);
  }

  public void getPos(CVector v) {
    nelmiscJNI.CMatrix_getPos__SWIG_0(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public CVector getPos() {
    return new CVector(nelmiscJNI.CMatrix_getPos__SWIG_1(swigCPtr, this), false);
  }

  public void getProj(SWIGTYPE_p_float proj) {
    nelmiscJNI.CMatrix_getProj(swigCPtr, this, SWIGTYPE_p_float.getCPtr(proj));
  }

  public CVector getI() {
    return new CVector(nelmiscJNI.CMatrix_getI(swigCPtr, this), true);
  }

  public CVector getJ() {
    return new CVector(nelmiscJNI.CMatrix_getJ(swigCPtr, this), true);
  }

  public CVector getK() {
    return new CVector(nelmiscJNI.CMatrix_getK(swigCPtr, this), true);
  }

  public void get(SWIGTYPE_p_float m44) {
    nelmiscJNI.CMatrix_get__SWIG_0(swigCPtr, this, SWIGTYPE_p_float.getCPtr(m44));
  }

  public SWIGTYPE_p_float get() {
    long cPtr = nelmiscJNI.CMatrix_get__SWIG_1(swigCPtr, this);
    return (cPtr == 0) ? null : new SWIGTYPE_p_float(cPtr, false);
  }

  public void translate(CVector v) {
    nelmiscJNI.CMatrix_translate(swigCPtr, this, CVector.getCPtr(v), v);
  }

  public void rotateX(float a) {
    nelmiscJNI.CMatrix_rotateX(swigCPtr, this, a);
  }

  public void rotateY(float a) {
    nelmiscJNI.CMatrix_rotateY(swigCPtr, this, a);
  }

  public void rotateZ(float a) {
    nelmiscJNI.CMatrix_rotateZ(swigCPtr, this, a);
  }

  public void rotate(CVector v, CMatrix.TRotOrder ro) {
    nelmiscJNI.CMatrix_rotate__SWIG_0(swigCPtr, this, CVector.getCPtr(v), v, ro.swigValue());
  }

  public void rotate(CQuat quat) {
    nelmiscJNI.CMatrix_rotate__SWIG_1(swigCPtr, this, CQuat.getCPtr(quat), quat);
  }

  public void scale(float f) {
    nelmiscJNI.CMatrix_scale__SWIG_0(swigCPtr, this, f);
  }

  public void scale(CVector scale) {
    nelmiscJNI.CMatrix_scale__SWIG_1(swigCPtr, this, CVector.getCPtr(scale), scale);
  }

  public void setMulMatrix(CMatrix m1, CMatrix m2) {
    nelmiscJNI.CMatrix_setMulMatrix(swigCPtr, this, CMatrix.getCPtr(m1), m1, CMatrix.getCPtr(m2), m2);
  }

  public CMatrix mul(CMatrix in) {
    return new CMatrix(nelmiscJNI.CMatrix_mul__SWIG_0(swigCPtr, this, CMatrix.getCPtr(in), in), true);
  }

  public CMatrix mulSelf(CMatrix in) {
    return new CMatrix(nelmiscJNI.CMatrix_mulSelf(swigCPtr, this, CMatrix.getCPtr(in), in), false);
  }

  public void setMulMatrixNoProj(CMatrix m1, CMatrix m2) {
    nelmiscJNI.CMatrix_setMulMatrixNoProj(swigCPtr, this, CMatrix.getCPtr(m1), m1, CMatrix.getCPtr(m2), m2);
  }

  public void transpose3x3() {
    nelmiscJNI.CMatrix_transpose3x3(swigCPtr, this);
  }

  public void transpose() {
    nelmiscJNI.CMatrix_transpose(swigCPtr, this);
  }

  public void invert() {
    nelmiscJNI.CMatrix_invert(swigCPtr, this);
  }

  public CMatrix inverted() {
    return new CMatrix(nelmiscJNI.CMatrix_inverted(swigCPtr, this), true);
  }

  public boolean normalize(CMatrix.TRotOrder pref) {
    return nelmiscJNI.CMatrix_normalize(swigCPtr, this, pref.swigValue());
  }

  public CVector mulVector(CVector v) {
    return new CVector(nelmiscJNI.CMatrix_mulVector(swigCPtr, this, CVector.getCPtr(v), v), true);
  }

  public CVector mulPoint(CVector v) {
    return new CVector(nelmiscJNI.CMatrix_mulPoint(swigCPtr, this, CVector.getCPtr(v), v), true);
  }

  public CVector mul(CVector v) {
    return new CVector(nelmiscJNI.CMatrix_mul__SWIG_1(swigCPtr, this, CVector.getCPtr(v), v), true);
  }

  public CVectorH mul(CVectorH v) {
    return new CVectorH(nelmiscJNI.CMatrix_mul__SWIG_2(swigCPtr, this, CVectorH.getCPtr(v), v), true);
  }

  public void serial(IStream f) {
    nelmiscJNI.CMatrix_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public boolean hasScalePart() {
    return nelmiscJNI.CMatrix_hasScalePart(swigCPtr, this);
  }

  public boolean hasScaleUniform() {
    return nelmiscJNI.CMatrix_hasScaleUniform(swigCPtr, this);
  }

  public float getScaleUniform() {
    return nelmiscJNI.CMatrix_getScaleUniform(swigCPtr, this);
  }

  public boolean hasProjectionPart() {
    return nelmiscJNI.CMatrix_hasProjectionPart(swigCPtr, this);
  }

  public final static class TRotOrder {
    public final static TRotOrder XYZ = new TRotOrder("XYZ");
    public final static TRotOrder XZY = new TRotOrder("XZY");
    public final static TRotOrder YXZ = new TRotOrder("YXZ");
    public final static TRotOrder YZX = new TRotOrder("YZX");
    public final static TRotOrder ZXY = new TRotOrder("ZXY");
    public final static TRotOrder ZYX = new TRotOrder("ZYX");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TRotOrder swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TRotOrder.class + " with value " + swigValue);
    }

    private TRotOrder(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TRotOrder(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TRotOrder(String swigName, TRotOrder swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TRotOrder[] swigValues = { XYZ, XZY, YXZ, YZX, ZXY, ZYX };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
